from frame.common.base.page_base import PageBase
from frame.common.browser import Browser
from frame.common.util.log_utils import logger as log
import unittest


# 初始化方法 结束后方法
class WebCaseBase(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        """
        全部用例集执行之前
        """
        log.info('--------测试集开始执行--------')

    @classmethod
    def tearDownClass(cls) -> None:
        """
        全部用例集执行之后
        """
        log.info('--------测试集执行结束--------')

    def setUp(self) -> None:
        # 打开浏览器
        self.base_page = PageBase(Browser().get_driver("chrome"))
        self.base_page.set_browser_max()
        self.base_page.impl_wait()
        pass

    def tearDown(self) -> None:
        # 对问题进行截图保存
        errors = self._outcome.errors
        for test, exc_info in errors:
            if exc_info:
                self.base_page.time_wait(1)
                self.base_page.screentshot_to_report()
        self.base_page.close()
        log.info('--------测试方法执行结束--------')
